<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<style>

    .layui-table th, .layui-table td{
        padding: 9px 6px;
        text-align: center;
    }
    .operation-menu a{
        margin: 5px 0;!important;
    }
    /*.layui-form select{*/
    /*display: inline-block;*/
    /*}*/
</style>
<body>
<div class="layui-fluid main">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <div class="layui-form-item" style="float: left;">
            <form class="layui-form serch" action="{:url('admin/Marketing/index')}" method="post">
                <div class="layui-form-item" style="float: left;">


                    <div class="layui-input-inline">
                        <input type="text" name="mk_id" value="{if isset($wherelist['mk_id'])}{$wherelist['mk_id']}{/if}" lay-verify="title" autocomplete="off" placeholder="活动ID" class="layui-input layui-btn-sm">
                    </div>
                    <div class="layui-input-inline">
                        <div class="layui-inline">

                            <input type="text" name="mk_name" value="{if isset($wherelist['mk_name'])}{$wherelist['mk_name']}{/if}" lay-verify="title" autocomplete="off" placeholder="活动名称" class="layui-input layui-btn-sm">
                            <!--<select name="coupon_types" lay-search="">-->
                            <!--<option value="">优惠券类型</option>-->
                            <!--<option value="1">折扣</option>-->
                            <!--<option value="2">满减</option>-->
                            <!--</select>-->
                        </div>
                    </div>

                    <div class="layui-input-inline">
                        <div class="layui-inline">
                            <select name="mk_status" lay-search="">
                                <option value="">活动状态</option>
                                <option value="0" {if isset($wherelist['mk_status']) AND $wherelist['mk_status']==0 }selected{/if}>活动结束</option>
                                <option value="1" {if isset($wherelist['mk_status']) AND $wherelist['mk_status']==1 }selected{/if}>进行中</option>
                                <option value="2" {if isset($wherelist['mk_status']) AND $wherelist['mk_status']==2 }selected{/if}>已删除</option>
                            </select>
                        </div>
                    </div>


                    <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">搜索</button>
                    <a href="{:url('admin/Marketing/addmk')}" class="layui-btn layui-btn-sm a_menu">
                        新增营销
                    </a>

                </div>
            </form>

        </div>
    </fieldset>
    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="5%">
            <col width="14%">
            <col width="14%">
            <col width="20%">
            <col width="14%">
            <col width="14%">
        </colgroup>
        <thead>

        <tr>
            <th>活动ID</th>
            <th>活动名称</th>
            <th>商品名称</th>
            <th>活动时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name='Mk' id='vo'}
        <tr>
            <td>{$vo.mk_id}</td>
            <td>{$vo.mk_name}</td>
            <td>{$vo.goods.goods_name}</td>
            <td>{$vo.mk_starttime|date="Y-m-d H:i",###} 至 {$vo.mk_endtime|date="Y-m-d H:i",###}</td>
            <td>
                {switch name="vo.mk_status"}
                {case value="0"}活动结束{/case}
                {case value="1"}活动进行中{/case}
                {case value="2"}活动禁止{/case}
                {default /}未知
                {/switch}
            </td>

            <td class="operation-menu">
                <a href="{:url('admin/Marketing/edit')}?id={$vo.mk_id}" class="layui-btn layui-btn-xs layui-btn-warm a_menu"  style="margin-right: 0;font-size:12px;background: darkslategrey">编辑</a>
                <a href="####" class="layui-btn layui-btn-xs layui-btn-warm delete " data-id="{$vo.goods_id}" id="{$vo.mk_id}" style="margin-right: 0;font-size:12px;background: #51a954">删除</a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div>{$Mk->render()}</div>

    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>

    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script type="text/javascript">

        $('.delete').click(function(){
            var mk_id = $(this).attr('id');
            var goods_id = $(this).attr('data-id');

            layer.confirm('确定要删除?', function(index) {
                $.ajax({
                    url:"{:url('admin/Marketing/del')}",
                    data:{mk_id:mk_id,goods_id:goods_id},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        })
        $('.shelves').click(function(){
            var id = $(this).attr('codeid');
            var goods_status= $(this).attr('data-id');
            layer.confirm('是否确定操作？', function(index) {
                $.ajax({
                    url:"{:url('admin/goods/shelves')}",
                    data:{id:id,goods_status:goods_status},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        })



        // $('.copy').click(function(){
        //     var id = $(this).attr('codeid');
        //     layer.confirm('确定复制吗?', function(index) {
        //         $.ajax({
        //             url:"{:url('admin/trip/copytrip')}",
        //             data:{id:id},
        //             success:function(res) {
        //                 layer.msg(res.msg);
        //                 if(res.code == 1) {
        //                     setTimeout(function(){
        //                         location.reload();
        //                     },1500)
        //                 }
        //             }
        //         })
        //     })
        // })

    </script>
    <script type="text/javascript">
        layui.use('layer', function(){
            var layer = layui.layer;
            $('.a_menu').click(function(){
                var url = $(this).attr('href');
                var a = 0;
                $.ajax({
                    url:url
                    ,async:false
                    ,success:function(res){
                        if(res.code == 0) {
                            layer.msg(res.msg);
                            a = 1;
                        }
                    }
                })
                if(a === 0) {
                    layer.open({
                        type:2,
                        content:url,
                        area: ['800px', '680px'],
                        end:function(){
                            location.reload();
                        }
                    });
                }
                return false;
            })

            $('.preview').click(function(){
                var url = $(this).attr('href');
                layer.open({
                    type:2,
                    content:url,
                    area: ['550px', '400px']
                });
                return false;
            })
        });
    </script>

</body>
</html>
